package com.dempsey.good.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dempsey.good.dao.Good;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author Dempsey
 * @description 针对表【goods】的数据库操作Mapper
 * @createDate 2022-05-02 01:40:40
 * @Entity com.dempsey.framework.dao.Goods
 */
@Mapper
public interface GoodMapper extends BaseMapper<Good> {

    List<Good> getGoodListByType(String goodType);

    List<Good> getGoodListByBrand(String goodBrand);

    @Update("UPDATE good \n" +
            "SET stock = ( SELECT a.stock - 1 FROM ( SELECT stock FROM good WHERE good_id = 2 ) a ) \n" +
            "WHERE good_id =#{goodId}")
    void delStock(int goodId);

}




